package com.benz.updatepack.ui;

import javax.swing.JPanel;
import com.jgoodies.forms.layout.FormLayout;
import com.benz.updatepack.ActionHandler;
import com.benz.updatepack.MainDatas;
import com.benz.updatepack.MainHandler;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.layout.FormSpecs;
import javax.swing.JLabel;
import javax.swing.JTextField;

import javax.swing.JTextArea;
import javax.swing.JButton;
import javax.swing.JFrame;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class MainPanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JTextField textField_packDate;
	private JTextField textField_packPath;
	private JTextField textField_packName;

	/**
	 * Create the panel.
	 */
	public MainPanel() {
		setLayout(new FormLayout(new ColumnSpec[] {
				FormSpecs.RELATED_GAP_COLSPEC,
				FormSpecs.DEFAULT_COLSPEC,
				FormSpecs.RELATED_GAP_COLSPEC,
				FormSpecs.DEFAULT_COLSPEC,
				FormSpecs.RELATED_GAP_COLSPEC,
				FormSpecs.DEFAULT_COLSPEC,
				FormSpecs.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("default:grow"),
				FormSpecs.RELATED_GAP_COLSPEC,
				FormSpecs.DEFAULT_COLSPEC,},
			new RowSpec[] {
				FormSpecs.RELATED_GAP_ROWSPEC,
				FormSpecs.DEFAULT_ROWSPEC,
				FormSpecs.RELATED_GAP_ROWSPEC,
				FormSpecs.DEFAULT_ROWSPEC,
				FormSpecs.RELATED_GAP_ROWSPEC,
				FormSpecs.DEFAULT_ROWSPEC,
				FormSpecs.RELATED_GAP_ROWSPEC,
				FormSpecs.DEFAULT_ROWSPEC,
				FormSpecs.RELATED_GAP_ROWSPEC,
				FormSpecs.DEFAULT_ROWSPEC,}));
		
		JLabel lblBenzweb = new JLabel("benz做的自动打包工具");
		add(lblBenzweb, "4, 2");
		
		JLabel label = new JLabel("请输入打包日期");
		add(label, "4, 4");
		
		textField_packDate = new JTextField();
		add(textField_packDate, "8, 4, fill, default");
		textField_packDate.setColumns(10);
		
		JLabel label_1 = new JLabel("请输入目标文件目录");
		add(label_1, "4, 6");
		
		textField_packPath = new JTextField();
		add(textField_packPath, "8, 6, fill, default");
		textField_packPath.setColumns(10);
		
		JButton button_exec = new JButton("下一步");
		button_exec.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		button_exec.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				/**
				String packDate = textField_packDate.getText();
				String packPath = textField_packPath.getText();
				String packSrcPath = textField_packSrcPath.getText();
				String packFilePaths = textArea_packFilePaths.getText();
//				String packFilePaths = "";
				ActionHandler.exec(packDate, packPath, packSrcPath, packFilePaths);
				
				**/
				MainDatas._packDate = textField_packDate.getText();
				MainDatas._packDestPath = textField_packPath.getText();
				MainDatas._packName = textField_packName.getText();

//				MainHandler.mainFrame.setVisible(false);
				MainHandler.frameStack.pop().setVisible(false);
				InputDetailPanel inputDetailPanel = new InputDetailPanel();
				JFrame inputDetailFrame = new JFrame();
				inputDetailFrame.getContentPane().add(inputDetailPanel);
				inputDetailFrame.setSize(800, 400);
				inputDetailFrame.setVisible(true);
				MainHandler.frameStack.push(inputDetailFrame);
			}
		});
		
		JLabel label_2 = new JLabel("更新包名称");
		add(label_2, "4, 8");
		
		textField_packName = new JTextField();
		add(textField_packName, "8, 8");
		textField_packName.setColumns(10);
		add(button_exec, "4, 10");

	}
	
	
	
}
